<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>创建可拖拽的标注</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
</head>
<body>
<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
<!--
<div class="map-tip">
<p>把当前位置设为该商户的精确位置？</p>
<p class="txtC4">（继续拖动图标重新定位）</p>
<div class="btn-row">
<ul class="adaptation">
<li><a class="map-btn left" href="#" id="correctOk">确定</a></li>
<li><a class="map-btn left" href="#" id="correctCancel">取消</a></li>

</ul>
</div>-->





</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("container");//在百度地图容器中创建一个地图
var point = new BMap.Point(121.623517,38.911717);//定义一个中心点坐标
map.centerAndZoom(point,13);//设定地图的中心点和坐标并将地图显示在地图容器中

map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
map.enableScrollWheelZoom();//启用地图滚轮放大缩小
map.enableDoubleClickZoom();//启用鼠标双击放大，默认启用(可不写)
map.disableKeyboard();//禁用键盘上下左右键移动地图，默认禁用(可不写)

//向地图中添加缩放控件
var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_SMALL});
map.addControl(ctrl_nav);
//向地图中添加缩略图控件
var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
map.addControl(ctrl_ove);

var iconimg = "http://api.map.baidu.com/library/MarkerTool/1.2/src/images/us_mk_icon.png";
var iconOld = new BMap.Icon(iconimg, new BMap.Size(23, 25), {anchor: new BMap.Size(9, 25), imageOffset: new BMap.Size(0, -21)});
var iconNew = new BMap.Icon(iconimg, new BMap.Size(23, 25), {anchor: new BMap.Size(9, 25), imageOffset: new BMap.Size(-23, -21)});

//覆盖层
var markerOld = new BMap.Marker(point);
var markerNew = new BMap.Marker(point);
markerOld.setIcon(iconOld);
markerNew.setIcon(iconNew);
markerNew.enableDragging(); // 设置标注可拖拽

map.addOverlay(markerOld);
map.addOverlay(markerNew);

markerNew.addEventListener("mouseup", function(e){
	var s = confirm("您确定标注位置？：" + this.getPosition().lng + ", " + this.getPosition().lat);
	if(s){
		markerOld.setPosition(markerNew.getPosition());
		//markerNew.disableDragging();
	}
});

</script>
